from MasterMind import *

block = Block(5)
password = Block(5)
pines = []
colors = ['blue','green','red','purple','orange','pink','lilac','brown','white','black']    
for color in colors:
    pines.append(Pine(color))
    
for pine in pines[:5]:
    password.add_pine(pine, pines.index(pine))


assert block.add_pine(pines[0], 0)
assert block.add_pine(pines[1], 1)
assert block.add_pine(pines[4], 2)
assert block.add_pine(pines[3], 3)
assert not block.add_pine(pines[4], 4)
assert block.add_pine(pines[6], 4)

result = password.result_block(block)
assert result.contains(pines[8])
assert result.contains(pines[9])

block.remove_pine(2)
block.remove_pine(4)

assert block.get_pine(2) == None
assert block.get_pine(4) == None

block.add_pine(pines[2], 2)
block.add_pine(pines[4], 4)

result = password.result_block(block)
assert result.contains(pines[9])
assert not result.contains(pines[8])
assert password == block